//
//  ArtTopicVideoViewController.m
//  ArtOfLiving
//
//  Created by 王文晓 on 16/5/5.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "ArtTopicVideoViewController.h"
#import "ArtTopvideoView.h"
#import "ArtTopDataModel.h"

@interface ArtTopicVideoViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *blurredImageView; //蒙版
@property (nonatomic, strong) ArtTopvideoView *videoView; //视频详情界面的底部view
@property (nonatomic, strong) UITapGestureRecognizer *tap; // 轻拍手势
@end

@implementation ArtTopicVideoViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
        //    添加底部view
    [self.view addSubview:self.videoView];
    
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark ---属性懒加载---
//视频详情界面的底部view
- (ArtTopvideoView *)videoView{
    
    if (!_videoView) {
       
        UINib *nib = [UINib nibWithNibName:@"ArtTopvideoView" bundle:nil];
        _videoView = [[nib instantiateWithOwner:nil options:nil] firstObject];
        _videoView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight-64);
            //        遍历传值数组进行赋值
        for (ArtTopDataModel *model in self.dataSourceMArr) {
            
            SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;
            //            图片蒙版
            [self.blurredImageView sd_setImageWithURL:[NSURL URLWithString:model.coverModel.blurred] placeholderImage:[UIImage imageNamed:@"artPlacehoder.png"] options:options];
            //            视频图片
            [_videoView.feedImageView sd_setImageWithURL:[NSURL URLWithString:model.coverModel.feed] placeholderImage:[UIImage imageNamed:@"artPlacehoder.png"] options:options];
            _videoView.titleLabel.text =model.title;
            _videoView.durationLabel.text = [NSString stringWithFormat:@"%@",model.duration];
            NSInteger time = [ _videoView.durationLabel.text intValue];
            NSInteger min = time/60; //获取分数
            NSInteger sec = time%60; //获取秒数
            NSString *timeStr = [NSString stringWithFormat:@"%02ld':%02ld''",min,sec];
            _videoView.durationLabel.text = timeStr;
            _videoView.categoryLabel.text = [NSString stringWithFormat:@"#%@",model.category];
            _videoView.descriptionLabel.text = model.descriptions;
            
            _videoView.playImage.userInteractionEnabled = YES;
            [_videoView.playImage addGestureRecognizer:self.tap];
            _videoView.collectionLabel.text = [NSString stringWithFormat:@"%@",model.consumptionModel.collectionCount];
            _videoView.shareLabel.text = [NSString stringWithFormat:@"%@",model.consumptionModel.shareCount];
            _videoView.downloadLabel.text = [NSString stringWithFormat:@"%@",model.consumptionModel.playCount];
        }
        
    }
    return _videoView;
}
//轻拍手势
-(UITapGestureRecognizer *)tap{
    
    if (!_tap) {
        
        _tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    }
    return _tap;
}
//手势回调
- (void)tapAction:(UITapGestureRecognizer *)sender{
    
    self.videoView.backgroundColor = [UIColor colorWithRed:1.000 green:1.000 blue:0.000 alpha:0.561];
    
}



//懒加载数据传值数组
- (NSMutableArray *)dataSourceMArr{
    
    if (!_dataSourceMArr) {
        
        _dataSourceMArr = [NSMutableArray array];
        
    }
    return _dataSourceMArr;
}


@end
